package cn.xiaopengstack.domain.rebate.event;

import cn.xiaopengstack.types.config.RocketMqTopicProperties;
import cn.xiaopengstack.types.event.BaseEvent;
import cn.xiaopengstack.types.utils.SpringContextUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;

import java.math.BigDecimal;

/**
 * @author jiangyangang
 * 发送用户返利事件
 */
@Slf4j
public class SendBehaviorRebateEvent<T> extends BaseEvent<SendBehaviorRebateEvent.SendBehaviorRebateMessage> {


    public SendBehaviorRebateEvent(SendBehaviorRebateMessage data, String key) {
        super(data, key);
    }

    @Override
    public String topic() {
        return SpringContextUtil.getBean(RocketMqTopicProperties.class).getSendRebateTopic();
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    public static class SendBehaviorRebateMessage{
        /** 用户ID */
        private String userId;
        /** 返利描述 */
        private String rebateDesc;
        /** 返利类型 */
        private String rebateType;
        /** 返利配置 */
        private String rebateConfig;
        /** 业务ID - 唯一ID，确保幂等 */
        private String bizId;
        /**
         * 行为发生的时间
         */
        private Long behaviorTime;

        /**
         * 返利的金额
         */
        private BigDecimal amount;
    }
}
